// add cupies
        private void Add_cupiesBtr(object sender, RoutedEventArgs e)
        {
            if (Checks.isTextInt(AmountTxt.Text))//add by yahav
            {
                item.AddCopies(int.Parse(AmountTxt.Text));

                System.Windows.Forms.MessageBox.Show("Stock Added!", "Sucess");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Number Is not Valid!!", "Eroor");
                AmountTxt.Text = "";
            }
        }
Exemple #2
0
        /// <summary>
        /// Learns a classification Extremely randomized trees model
        /// </summary>
        /// <param name="observations"></param>
        /// <param name="targets"></param>
        /// <param name="indices"></param>
        /// <returns></returns>
        public ClassificationForestModel Learn(F64Matrix observations, double[] targets,
                                               int[] indices)
        {
            Checks.VerifyObservationsAndTargets(observations, targets);
            Checks.VerifyIndices(indices, observations, targets);

            if (m_featuresPrSplit == 0)
            {
                var count = (int)Math.Sqrt(observations.ColumnCount);
                m_featuresPrSplit = count <= 0 ? 1 : count;
            }

            var results = new ConcurrentDictionary <int, ClassificationDecisionTreeModel>();

            // Ensure each tree (index) is always created with the same random generator,
            // in both sequential and parallel mode.
            var treeIndex = 0;
            var treeIndexToRandomGenerators = Enumerable.Range(0, m_trees)
                                              .Select(v => new { Index = treeIndex++, Random = new Random(m_random.Next()) })
                                              .ToArray();

            if (!m_runParallel)
            {
                foreach (var indexToRandom in treeIndexToRandomGenerators)
                {
                    var tree = CreateTree(observations, targets,
                                          indices, indexToRandom.Random);

                    results.TryAdd(indexToRandom.Index, tree);
                }
            }
            else
            {
                var rangePartitioner = Partitioner.Create(treeIndexToRandomGenerators, true);
                Parallel.ForEach(rangePartitioner, (indexToRandom, loopState) =>
                {
                    var tree = CreateTree(observations, targets,
                                          indices, indexToRandom.Random);

                    results.TryAdd(indexToRandom.Index, tree);
                });
            }

            // Ensure the order of the trees.
            var models = results.OrderBy(v => v.Key).Select(v => v.Value).ToArray();

            var rawVariableImportance = VariableImportance(models, observations.ColumnCount);

            return(new ClassificationForestModel(models, rawVariableImportance));
        }
Exemple #3
0
        public static T[] Reverse <T>(T[] array)
        {
            Checks.NotNull(array);
            var copy = Make <T>(array.Length);
            var j    = 0;

            for (var i = array.Length - 1; i >= 0; i--)
            {
                copy[j] = array[i];
                j++;
            }

            return(copy);
        }
Exemple #4
0
    //Button to like the IMAGE
    protected void BtnLike_Click(object sender, EventArgs e)
    {
        MembershipUser currentUser   = Membership.GetUser();
        Guid           currentUserId = (Guid)currentUser.ProviderUserKey;;


        //Get Image ID
        string strImageId = ((Label)FVImageLikesAndInfo.FindControl("lblImageIdForUndef")).Text;

        string qstr = Request.QueryString["img"];


        string ConnectionString  = Checks.getConnectionString();
        string insertSqlBtnLikes = "INSERT INTO Cus_ImageLikes(UserId, ImageId, ImageName) VALUES(@UserId, @ImageId, @ImageName)";
        string UpdateSqlBtnkLike = "UPDATE Cus_Upload SET NumOfLikes= NumOfLikes+1   WHERE ImageId=@ImageId";

        //notofication insert
        string insertSqlNotif = "INSERT INTO Cus_Notif(UserId, UserName, ProfileName, NotifBody, IsRead, ImageName) VALUES(@UserId, @UserName, @ProfileName, @NotifBody, @isRead, @ImageName)";

        using (SqlConnection myConnection = new SqlConnection(ConnectionString))
        {
            myConnection.Open();
            SqlCommand BtnLikes = new SqlCommand(insertSqlBtnLikes, myConnection);

            BtnLikes.Parameters.AddWithValue("@UserId", currentUserId);
            BtnLikes.Parameters.AddWithValue("@ImageId", strImageId);
            BtnLikes.Parameters.AddWithValue("@ImageName", qstr);
            BtnLikes.ExecuteNonQuery();
            SqlCommand BtnkLike = new SqlCommand(UpdateSqlBtnkLike, myConnection);
            BtnkLike.Parameters.AddWithValue("@ImageId", strImageId);
            BtnkLike.ExecuteNonQuery();


            //notif
            SqlCommand Notif       = new SqlCommand(insertSqlNotif, myConnection);
            string     notifBody   = "liked your photo";
            string     isRead      = "NEW";
            string     profileName = Session["forMotherRussia"].ToString();
            Notif.Parameters.AddWithValue("@UserId", currentUserId);
            Notif.Parameters.AddWithValue("@UserName", profileName);
            Notif.Parameters.AddWithValue("@ProfileName", currentUser.ToString());
            Notif.Parameters.AddWithValue("@NotifBody", notifBody);
            Notif.Parameters.AddWithValue("@isRead", isRead);
            Notif.Parameters.AddWithValue("@ImageName", qstr);
            Notif.ExecuteNonQuery();
        }

        //reload page
        Page.Response.Redirect(Page.Request.Url.ToString(), true);
    }
Exemple #5
0
        protected BaseWritableDirectory(string path)
        {
            Assert.IsFalse(UsedPaths.Contains(path),
                           string.Format("You cannot create two instances of {0} pointing to the same path.", typeof(T)));
            Checks.ArgumentNotNullOrEmpty(path, "path");

            DebugLogger.LogConstructor();
            DebugLogger.LogVariable(path, "path");

            _path = path;

            // Register path as used.
            UsedPaths.Add(_path);
        }
        public override void Prepare(IStatusMonitor statusMonitor)
        {
            base.Prepare(statusMonitor);

            Checks.ArgumentNotNull(statusMonitor, "statusMonitor");

            DebugLogger.Log("Preparing uninstallation.");

            _localData.PrepareForWriting();

            double weight = StatusWeightHelper.GetUninstallWeight();

            _statusReporter = statusMonitor.CreateGeneralStatusReporter(weight);
        }
Exemple #7
0
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="body">() => new User() { Name = "lu", Age = 18, Gender = Gender.Man, CityId = 1, OpTime = DateTime.Now }</param>
        /// <returns></returns>
        public string Add(Expression <Func <TEntity> > body)
        {
            Checks.NotNull(body, "body");

            TypeDescriptor typeDescriptor = TypeDescriptor.GetDescriptor(typeof(TEntity));



            Dictionary <MemberInfo, Expression> insertColumns = InitMemberExtractor.Extract(body);

            DbInsertExpression e = new DbInsertExpression(typeDescriptor.Table);

            string keyVal = null;

            foreach (var kv in insertColumns)
            {
                MemberInfo key = kv.Key;
                MappingMemberDescriptor memberDescriptor = typeDescriptor.TryGetMappingMemberDescriptor(key);
                object val = ExpressionEvaluator.Evaluate(kv.Value);
                //如果是主键
                if (memberDescriptor.SZColumnAttribute.IsKey)
                {
                    if (val == null || string.IsNullOrEmpty(val.ToString()))
                    {
                        val    = GetNewKey();
                        keyVal = val.ToString();
                        e.InsertColumns.Add(memberDescriptor.Column, DbExpression.Parameter(keyVal));
                        continue;
                    }
                }
                //如果是添加或修改时间
                if (memberDescriptor.SZColumnAttribute.IsAddTime || memberDescriptor.SZColumnAttribute.IsEditTime)
                {
                    val = DateTime.Now;
                    e.InsertColumns.Add(memberDescriptor.Column, DbExpression.Parameter(keyVal));
                    continue;
                }
                DbExpression valExp = DbExpression.Parameter(val, memberDescriptor.MemberInfoType);
                e.InsertColumns.Add(memberDescriptor.Column, valExp);
            }


            IDbExpressionTranslator translator = this.DbContext.DatabaseProvider.CreateDbExpressionTranslator();
            List <DbParam>          parameters;
            string sql = translator.Translate(e, out parameters);

            this.DbContext.ExecuteNoQuery(sql, parameters.ToArray());
            return(keyVal);
        }
Exemple #8
0
        private void InitializeConfig()
        {
            try
            {
                Checks.Add(new SystemStatsCheck());

                _networkTrafficCheck = new NetworkTrafficCheck();

                Checks.Add(_networkTrafficCheck);
                Checks.Add(new DriveInfoBasedDiskUsageCheck());
                Checks.Add(new ProcessorCheck());
                Checks.Add(new ProcessCheck());
                Checks.Add(new PhysicalMemoryFreeCheck());
                Checks.Add(new PhysicalMemoryUsedCheck());
                Checks.Add(new PhysicalMemoryCachedCheck());
                Checks.Add(new SwapMemoryFreeCheck());
                Checks.Add(new SwapMemoryUsedCheck());

                if (_config.IISStatus)
                {
                    Checks.Add(new IISCheck());
                }

                if (_config.PluginDirectory != null && Directory.Exists(_config.PluginDirectory))
                {
                    Checks.Add(new PluginCheck(_config.PluginDirectory));
                }

                if (_config.SQLServerStatus)
                {
                    Checks.Add(new SQLServerCheck(_config.CustomPrefix));
                }

                if (!string.IsNullOrEmpty(_config.MongoDBConnectionString))
                {
                    Checks.Add(new ExtendedMongoDBCheck(_config.MongoDBConnectionString, _config.MongoDBReplSet, _config.MongoDBDBStats));
                }

                // flag check
                if (Agent.Flags.ContainsKey("FlagCheck"))
                {
                    Log.Warn("Flag check activated");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Exemple #9
0
        /// <summary>
        ///  A series of regression trees are fitted stage wise on the residuals of the previous tree
        /// </summary>
        /// <param name="observations"></param>
        /// <param name="targets"></param>
        /// <param name="indices"></param>
        /// <returns></returns>
        public RegressionGradientBoostModel Learn(F64Matrix observations, double[] targets, int[] indices)
        {
            Checks.VerifyObservationsAndTargets(observations, targets);
            Checks.VerifyIndices(indices, observations, targets);

            var rows            = observations.RowCount;
            var orderedElements = CreateOrderedElements(observations, rows);

            var inSample = targets.Select(t => false).ToArray();

            indices.ForEach(i => inSample[i] = true);
            var workIndices = indices.ToArray();

            var trees = new GBMTree[m_iterations];

            var initialLoss = m_loss.InitialLoss(targets, inSample);
            var predictions = targets.Select(t => initialLoss).ToArray();
            var residuals   = new double[targets.Length];

            var predictWork = new double[observations.RowCount];

            for (int iteration = 0; iteration < m_iterations; iteration++)
            {
                m_loss.UpdateResiduals(targets, predictions, residuals, inSample);

                var sampleSize = targets.Length;
                if (m_subSampleRatio != 1.0)
                {
                    sampleSize = (int)Math.Round(m_subSampleRatio * workIndices.Length);
                    var currentInSample = Sample(sampleSize, workIndices, targets.Length);

                    trees[iteration] = m_learner.Learn(observations, targets, residuals,
                                                       predictions, orderedElements, currentInSample);
                }
                else
                {
                    trees[iteration] = m_learner.Learn(observations, targets, residuals,
                                                       predictions, orderedElements, inSample);
                }

                trees[iteration].Predict(observations, predictWork);
                for (int i = 0; i < predictWork.Length; i++)
                {
                    predictions[i] += m_learningRate * predictWork[i];
                }
            }

            return(new RegressionGradientBoostModel(trees, m_learningRate, initialLoss, observations.ColumnCount));
        }
Exemple #10
0
        /// <summary>
        /// 条件删除
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public int Remove(Expression <Func <TEntity, bool> > condition)
        {
            Checks.NotNull(condition, "condition");

            TypeDescriptor typeDescriptor = TypeDescriptor.GetDescriptor(typeof(TEntity));
            DbExpression   conditionExp   = typeDescriptor.Visitor.VisitFilterPredicate(condition);

            DbDeleteExpression e = new DbDeleteExpression(typeDescriptor.Table, conditionExp);

            IDbExpressionTranslator translator = this.DbContext._dbContextServiceProvider.CreateDbExpressionTranslator();
            List <DbParam>          parameters;
            string sql = translator.Translate(e, out parameters);

            return(this.DbContext.ExecuteNoQuery(sql, parameters.ToArray()));
        }
        public override void Prepare(UpdaterStatus status)
        {
            base.Prepare(status);

            Checks.ArgumentNotNull(status, "statusMonitor");

            DebugLogger.Log("Preparing version integrity check.");

            _status = new OperationStatus
            {
                Weight      = { Value = StatusWeightHelper.GetCheckVersionIntegrityWeight(_versionSummary) },
                Description = { Value = "Checking version integrity..." }
            };
            status.RegisterOperation(_status);
        }
 private void RegisterBtn_Click(object sender, RoutedEventArgs e)
 {
     if (!Checks.IsNotEmptyNullOrWhite(UserTxt.Text) || !Checks.IsNotEmptyNullOrWhite(PassTxt.Text))
     {
         System.Windows.Forms.MessageBox.Show("Please enter account id", "Error!");
         return;
     }
     if (!LibraryManager.Register(UserTxt.Text, PassTxt.Text))
         System.Windows.Forms.MessageBox.Show("User already exist","Erro!");
     else
     {
         System.Windows.Forms.MessageBox.Show("Account was added succesfully!","Account added!");
         this.Close();
     }
 }
Exemple #13
0
        /// <summary>
        /// Learns a stacking classification ensemble on the provided indices
        /// </summary>
        /// <param name="observations"></param>
        /// <param name="targets"></param>
        /// <param name="indices"></param>
        /// <returns></returns>
        public ClassificationStackingEnsembleModel Learn(F64Matrix observations, double[] targets, int[] indices)
        {
            Checks.VerifyObservationsAndTargets(observations, targets);
            Checks.VerifyIndices(indices, observations, targets);

            var metaObservations = LearnMetaFeatures(observations, targets, indices);

            var metaModelTargets = targets.GetIndices(indices);
            var metaModel        = m_metaLearner(metaObservations, metaModelTargets);
            var ensembleModels   = m_learners.Select(learner => learner.Learn(observations, targets, indices)).ToArray();

            var numberOfClasses = targets.Distinct().Count();

            return(new ClassificationStackingEnsembleModel(ensembleModels, metaModel, m_includeOriginalFeaturesForMetaLearner, numberOfClasses));
        }
        /// <summary>
        /// Learns a stacking classification ensemble on the provided indices
        /// </summary>
        /// <param name="observations"></param>
        /// <param name="targets"></param>
        /// <param name="indices"></param>
        /// <returns></returns>
        public RegressionEnsembleModel Learn(F64Matrix observations, double[] targets, int[] indices)
        {
            Checks.VerifyObservationsAndTargets(observations, targets);
            Checks.VerifyIndices(indices, observations, targets);

            var metaObservations = LearnMetaFeatures(observations, targets, indices);

            var metaModelTargets     = targets.GetIndices(indices);
            var ensembleModelIndices = m_ensembleSelection.Select(metaObservations, metaModelTargets);

            var ensembleModels = m_learners.GetIndices(ensembleModelIndices)
                                 .Select(learner => learner.Learn(observations, targets, indices)).ToArray();

            return(new RegressionEnsembleModel(ensembleModels, m_ensembleStrategy()));
        }
 private void SearchByISBNBtr(object sender, RoutedEventArgs e)// By ISBN
 {
     if (!Checks.IsNotEmptyNullOrWhite(SearchBoxTxt.Text))
     {
         System.Windows.Forms.MessageBox.Show("You need to insert a value");
         return;
     }
     if (!libraryManager.GetObject(1, SearchBoxTxt, InfoTxt, BookTxt, RemoveBtn))
     {
         InfoTxt.Text = "";
         BookTxt.Text = "";
         System.Windows.Forms.MessageBox.Show("Cannot Find ISBN!", "Error");
     }
     SearchBoxTxt.Text = "";
 }
 public void Setup(Puzzle puzzle)
 {
     Current = puzzle;
     CurrentPuzzleStartedUtc = DateTime.UtcNow;
     CurrentPuzzleEndedUtc   = null;
     PossibleVariations      = puzzle.Solutions.Select(x => x.Split(' '));
     FENs.Clear();
     FENs.Add(puzzle.InitialFen);
     Checks.Clear();
     Checks.Add(Current.Game.IsInCheck(Current.Game.WhoseTurn) ? Current.Game.WhoseTurn.ToString().ToLowerInvariant() : null);
     Moves.Clear();
     Moves.Add(null);
     Pockets.Clear();
     Pockets.Add(Current.Game.GenerateJsonPocket());
 }
        public void InvalidDataTypes()
        {
            var checks = new Checks <ValidationDataType, object, object>()
            {
                { ValidationDataType.Currency, 1m, this },
                { ValidationDataType.Date, DateTime.Now, 1.1 },
                { ValidationDataType.Double, 1d, this },
                { ValidationDataType.Integer, 1, 1.1 }
            };

            foreach (var check in checks)
            {
                CheckForInvalidDataType(check.Item1, check.Item2, check.Item3);
            }
        }
Exemple #18
0
 public IntValidator(TextBox control, TextBlock error_block, bool required, int?min, int?max, params Func <TextBox, string>[] checks) : this(control, error_block, checks)
 {
     if (required)
     {
         Checks.Add(c => c.Text == "" ? "Error: This field is required." : "");
     }
     if (min != null)
     {
         Checks.Add(c => int.Parse(c.Text) < (int)min ? "Error: Number must be at least " + (int)min + '.' : "");
     }
     if (max != null)
     {
         Checks.Add(c => int.Parse(c.Text) > (int)max ? "Error: Number must be at most " + (int)max + '.' : "");
     }
 }
Exemple #19
0
 public IntValidator(TextBox control, TextBlock error_block, params Func <TextBox, string>[] checks) : base(control, error_block, checks)
 {
     Checks.Add(
         c => {
         try {
             c.Text = string.IsNullOrWhiteSpace(c.Text) ? "" : int.Parse(c.Text).ToString();
             return("");
         } catch (FormatException) {
             return("Error: Input must be a number.");
         } catch (OverflowException) {
             return("Error: Number is too large.");
         }
     }
         );
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="EventHubPartitionContext"/> class.
        /// </summary>
        /// <param name="azurePartitionContext">The <see cref="AzurePartitionContext"/> instance.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if the given <see cref="AzurePartitionContext"/> instance is null.
        /// </exception>
        public EventHubPartitionContext(
            AzurePartitionContext azurePartitionContext)
        {
            Checks.Parameter(
                nameof(azurePartitionContext),
                azurePartitionContext)
            .NotNull();

            this.azurePartitionContext = azurePartitionContext;

            this.lazyReceiverRuntimneInfo =
                new Lazy <EventHubReceiverRuntimeInformation>(
                    () => new EventHubReceiverRuntimeInformation(
                        this.azurePartitionContext.RuntimeInformation));
        }
        public FilePatcher(string filePath, string diffPath, string outputFilePath)
        {
            Checks.ArgumentFileExists(filePath, "filePath");
            Checks.ArgumentFileExists(diffPath, "diffPath");
            Checks.ArgumentParentDirectoryExists(outputFilePath, "outputFilePath");

            DebugLogger.LogConstructor();
            DebugLogger.LogVariable(filePath, "filePath");
            DebugLogger.LogVariable(diffPath, "diffPath");
            DebugLogger.LogVariable(outputFilePath, "outputFilePath");

            _filePath       = filePath;
            _diffPath       = diffPath;
            _outputFilePath = outputFilePath;
        }
Exemple #22
0
        /// <summary>
        /// Adds an association between the specified tag name and all of the specied checks.
        /// Makes sure the tag exists (creates it if it doesn't exist)
        /// </summary>
        /// <param name="tag">Tag to be applied to checks</param>
        /// <param name="checks">Collection of checks to apply the tag to.</param>
        public void ApplyTagToChecks(string tag, IEnumerable <string> checks)
        {
            AddMissingTags(new[] { tag });
            var tagRow = Tags.Single(r => r.Tag.Equals(tag));

            foreach (var check in checks)
            {
                var checkRow = Checks.Single(c => c.Name.Equals(check));
                if (CheckTags.Any(row => row.TagID == tagRow.ID && row.CheckID == checkRow.ID))
                {
                    continue;
                }
                CheckTags.AddCheckTagsRow(checkRow, tagRow);
            }
        }
Exemple #23
0
        public ChunkedHttpDownloader(string destinationFilePath, RemoteResource resource, int timeout)
        {
            Checks.ArgumentParentDirectoryExists(destinationFilePath, "destinationFilePath");
            Checks.ArgumentValidRemoteResource(resource, "resource");
            Checks.ArgumentMoreThanZero(timeout, "timeout");

            DebugLogger.LogConstructor();
            DebugLogger.LogVariable(destinationFilePath, "destinationFilePath");
            DebugLogger.LogVariable(resource, "resource");
            DebugLogger.LogVariable(timeout, "timeout");

            _destinationFilePath = destinationFilePath;
            _resource            = resource;
            _timeout             = timeout;
        }
        public void RegisterEntry(string entryName, int versionId)
        {
            Checks.ArgumentNotNullOrEmpty(entryName, "fileName");
            Checks.ArgumentValidVersionId(versionId, "versionId");

            // TODO: Uncomment this after fixing directory registration in install content command
            Assert.IsFalse(entryName.EndsWith("/"),
                           "Cannot register directory as entry due to problem with content installation command. See code to learn more.");

            DebugLogger.Log(string.Format("Adding or updating file {0} to version {1}.", entryName, versionId));

            _data.FileVersionIds[entryName] = versionId;

            SaveData();
        }
Exemple #25
0
    protected void BtnFollow_Click(object sender, EventArgs e)
    {
        MembershipUser currentUser   = Membership.GetUser();
        Guid           currentUserId = (Guid)currentUser.ProviderUserKey;;

        string userId      = ((Label)FVUserInfoShow.FindControl("UserIdLabel")).Text;
        string profileName = ((Label)FVUserInfoShow.FindControl("UserNameLabel")).Text;

        string ConnectionString = Checks.getConnectionString();
        //follow insert
        string insertSqlBtnFollow = "INSERT INTO Cus_Followers2(UserId, UserName, ProfileName, FUserId, FUserName, FProfileName) VALUES(@UserId, @UserName, @ProfileName, @FUserId, @FUserName, @FProfileName)";


        //notofication insert
        string insertSqlNotif = "INSERT INTO Cus_Notif(UserId, UserName, ProfileName, NotifBody, IsRead) VALUES(@UserId, @UserName, @ProfileName, @NotifBody, @isRead)";

        using (SqlConnection myConnection = new SqlConnection(ConnectionString))
        {
            myConnection.Open();

            //followers
            SqlCommand BtnFollow = new SqlCommand(insertSqlBtnFollow, myConnection);

            BtnFollow.Parameters.AddWithValue("@UserId", currentUserId);
            BtnFollow.Parameters.AddWithValue("@UserName", currentUser.ToString());
            BtnFollow.Parameters.AddWithValue("@ProfileName", currentUser.ToString());
            BtnFollow.Parameters.AddWithValue("@FUserId", userId);
            BtnFollow.Parameters.AddWithValue("@FUserName", profileName);
            BtnFollow.Parameters.AddWithValue("@FProfileName", profileName);
            BtnFollow.ExecuteNonQuery();



            //notif
            SqlCommand Notif     = new SqlCommand(insertSqlNotif, myConnection);
            string     notifBody = "started following you";
            string     isRead    = "NEW";
            Notif.Parameters.AddWithValue("@UserId", currentUserId);
            Notif.Parameters.AddWithValue("@UserName", profileName);
            Notif.Parameters.AddWithValue("@ProfileName", currentUser.ToString());
            Notif.Parameters.AddWithValue("@NotifBody", notifBody);
            Notif.Parameters.AddWithValue("@isRead", isRead);
            Notif.ExecuteNonQuery();
        }


        Page.Response.Redirect(Page.Request.Url.ToString(), true);
    }
        /// <summary>
        /// Learns a decision tree from the provided observations and targets but limited to the observation indices provided by indices.
        /// Indices can contain the same index multiple times. Weights can be provided in order to weight each sample individually
        /// </summary>
        /// <param name="observations"></param>
        /// <param name="targets"></param>
        /// <param name="indices"></param>
        /// <param name="weights">Provide weights inorder to weigh each sample separetely</param>
        /// <returns></returns>
        public BinaryTree Learn(F64MatrixView observations, double[] targets, int[] indices, double[] weights)
        {
            Checks.VerifyObservationsAndTargets(observations, targets);
            Checks.VerifyIndices(indices, observations, targets);

            // Verify weights dimensions. Currently sample weights is supported by DecisionTreeLearner.
            // Hence, the check is not added to the general checks.
            if (weights.Length != 0)
            {
                if (weights.Length != targets.Length || weights.Length != observations.RowCount)
                {
                    throw new ArgumentException($"Weights length differ from observation row count and target length. Weights: {weights.Length}, observation: {observations.RowCount}, targets: {targets.Length}");
                }
            }
            return(m_treeBuilder.Build(observations, targets, indices, weights));
        }
Exemple #27
0
        public override void Prepare(UpdaterStatus status, CancellationToken cancellationToken)
        {
            base.Prepare(status, cancellationToken);

            Checks.ArgumentNotNull(status, "statusMonitor");

            DebugLogger.Log("Preparing uninstallation.");

            _localData.PrepareForWriting();

            _statusReporter = new OperationStatus
            {
                Weight = { Value = StatusWeightHelper.GetUninstallWeight() }
            };
            status.RegisterOperation(_statusReporter);
        }
Exemple #28
0
        TResult ExecuteAggregateQuery <TResult>(MethodInfo method, Expression argument, bool checkArgument = true)
        {
            if (checkArgument)
            {
                Checks.NotNull(argument, "argument");
            }

            List <Expression> arguments = argument == null ? EmptyArgumentList : new List <Expression>(1)
            {
                argument
            };

            IEnumerable <TResult> iterator = this.CreateAggregateQuery <TResult>(method, arguments);

            return(iterator.Single());
        }
        public CheckVersionIntegrityCommand(int versionId, AppContentSummary versionSummary, ILocalDirectory localDirectory, ILocalMetaData localMetaData)
        {
            Checks.ArgumentValidVersionId(versionId, "versionId");
            // TODO: Validate the content summary.
            Checks.ArgumentNotNull(localDirectory, "localDirectory");
            Checks.ArgumentNotNull(localMetaData, "localMetaData");


            DebugLogger.LogConstructor();
            DebugLogger.LogVariable(versionId, "versionId");

            _versionId      = versionId;
            _versionSummary = versionSummary;
            _localDirectory = localDirectory;
            _localMetaData  = localMetaData;
        }
        public DownloadPackageCommand(RemoteResource resource, string destinationPackagePath, string destinationMetaPath, bool useTorrents)
        {
            Checks.ArgumentValidRemoteResource(resource, "resource");
            Checks.ArgumentNotNullOrEmpty(destinationPackagePath, "destinationPackagePath");
            Checks.ParentDirectoryExists(destinationPackagePath);

            DebugLogger.LogConstructor();
            DebugLogger.LogVariable(resource, "resource");
            DebugLogger.LogVariable(destinationPackagePath, "destinationPackagePath");
            DebugLogger.LogVariable(useTorrents, "useTorrents");

            _resource = resource;
            _destinationPackagePath = destinationPackagePath;
            _destinationMetaPath    = destinationMetaPath;
            _useTorrents            = useTorrents;
        }